<%@page import="diplom.shop.web.*"%>
<%@page import="diplom.shop.domain.*"%>
<%@page import="diplom.shop.services.*"%>
<%@page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="../js/jquery.js" type="text/javascript" ></script>
<script src="../js/myjs.js" type="text/javascript" ></script>

<title>Insert title here</title>
</head>
<body>
<%
	//if(!MouseWeb.isCategoryIdSet(request)){
List<Category> categoryList = DeviceWeb.getCategoryList();
for(Category cat : categoryList)
	out.println("<a href=\"addNewDevice.jsp?category="+cat.getCategoryId()+"\">"+cat.getCategoryName()+"</a></br>");

//}
//вирубити ці довбані силки і замутити через збереження в сешин
%>


<form id="addNewDevicForm" name="addNewDevicForm" action="addServlet" method="post">
		<table>
		<tr>
		<td><label>Категорія товару</label></td>
		<td><select id="category" name="category">
		<option selected disabled value ="0">Выберите героя</option>				
			<option value="26">Mouse</option>
			<option value="28">Processor</option>
			<option value="30">Motherboard</option>
		</select> </td> 
		</tr>
		<tr>
		<td><label>Назва товару</label></td>
		<td><input type="text" id="deviceName"	name="deviceName" /></td> 
		</tr>
		<tr>
		<td><label>Вартість</label></td>
		<td><input type="text"	id="cost" name="cost" /></td> 
		</tr>
		<tr>
		<td><label>Гарантія</label></td>
		<td><input type="text" id="guaranty" name="guaranty" /></td> 
		</tr>
		<tr>
		<td><label>Фото</label></td>
		<td><input type="text" id="image" name="image" /></td> 
		</tr>
	 	
		<%
	
	 								if(DeviceWeb.isCategoryIdSet(request)){
	 												
	 												Category category = DeviceWeb.getCategoryById(request);
	 													out.print(category.getCategoryId()+ " Id category ;");
	 												   	session.setAttribute("category",category.getCategoryId());
	 													out.print(request.getAttribute("category")+ " request" );
	 													out.print(session.getAttribute("category")+ " session");
	 												List<ArrayList<String>> mouseForm = DomainServices.getForm(category.getCategoryId());
	 												for(ArrayList<String> s : mouseForm) {
	 	%>
	 						<td><label><% out.print(s.get(0));%></label></td>
	 						<td><input 	id="<% out.print(s.get(1));%>" name="<%out.print(s.get(1));%>"	type="text" /></td>
						</tr>
						<%
							}}
						%>
						</table>						
						<input type="submit" value="Send" />
					</form>
<div id="getForm">
</div>
</body>
</html>